package model

import (
	"fmt"
	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)

type Entity struct {
	img    *ebiten.Image
	Width  int
	Height int
	X      float64
	Y      float64
}

func NewEntity(path string) *Entity {
	image, _, err := ebitenutil.NewImageFromFile(path)
	if err != nil {
		fmt.Println("coin图片加载失败")
		panic(err)
	}
	w := image.Bounds().Dx()
	h := image.Bounds().Dy()
	return &Entity{
		img:    image,
		Width:  w,
		Height: h,
		X:      0,
		Y:      0,
	}
}

func (e *Entity) DrawScreen(screen *ebiten.Image) {
	op := &ebiten.DrawImageOptions{}
	op.GeoM.Translate(e.X, e.Y)
	screen.DrawImage(e.img, op)
}
